// pages/mine/myTopic/myTopic.js

let {
  api_GetTopicByUserid
} = require("../../api/getData.js")
const app = getApp()

Page({
  /**
   * 页面的初始数据
   */
  data: {
    topicInfo:[],
    userid:"",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var data={
      userid: app.globalData.userInfo.id,
    }
    api_GetTopicByUserid(data, (res) => {
      var arrayTmp = [];
      res.data.forEach(i => {
        var imgUrlList = []
        var tmp = i;
        for (var m = 0; m < tmp.piclen; m++) {
          imgUrlList.push(app.globalData.static_url + "topic/" + tmp.id + "/" + (m + 1) + ".png")
        }
        tmp.imgUrlList = imgUrlList;
        arrayTmp.push(tmp)
      })
      this.setData({
        dataSource: arrayTmp,
      })
    })
  },

  bindMakeComment: function (e) {
    var topic = e.currentTarget.dataset.index;
    console.log('当前点击的活动ID==>', topic.id);
    var dataTmp = JSON.stringify(topic);
    wx.navigateTo({
      url: '../../mine/question/question?topic=' + dataTmp,
      success: function (res) {
        // success
      },
      fail: function () {
        // fail
      },
    })
  },

})